package com.itheima.mapper;

import com.itheima.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper {

    /**
     * @description:查询所有
     * @author: yanhongwei 
     * @date: 2023/3/16 17:07
     * @param: []
     * @return: java.util.List<com.itheima.pojo.Brand>
     **/
    @Select("select * from tb_brand")
    @ResultMap("brandResultMap")
    List<Brand> selectAll();

    /**
     * @description:添加数据
     * @author: yanhongwei
     * @date: 2023/3/16 18:54
     * @param: [brand]
     * @return: void
     **/
    @Insert("insert into tb_brand(brand_name,company_name,ordered,description,status)values(#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);

    @Delete("delete from tb_brand where id=#{id}")
    void del(@Param("id")int id);

    void delAll(@Param("ids") int[] ids);

    @Select("select * from tb_brand limit #{begin},#{size}")
    @ResultMap("brandResultMap")
    List<Brand> selectByPage(@Param("begin")int begin,@Param("size")int size);

    @Select("select count(1) from tb_brand")
    int selectTotalCount();


    List<Brand> selectByPageAndCondition(@Param("begin")int begin,@Param("size")int size,@Param("brand") Brand brand);

    int selectTotalCountByCondition(Brand brand);
}
